package com.wen.task.customTask;

import com.wen.moudle.Account;
import com.wen.moudle.Managers.BackpackManager;
import com.wen.task.AbstractTask;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class UsePill extends AbstractTask {
    BackpackManager backpackManager;

    public UsePill(Account account) {
        super(account);
        backpackManager = getBackpackManager();
    }

    @Override
    public void run() {
        use50Pills("经验丸");
        use50Pills("敏捷丸");
        use50Pills("大力丸");
        use50Pills("速度丸");
    }

    @Override
    public String getTitle() {
        return "一键使用50个buff药丸";
    }

    public void use50Pills(String name){
        int id = backpackManager.getGoodId(name);
        int count = 0;
        int group = 0;
        while (backpackManager.useGood(id).isSuccess()) {
            count++;
            group++;
            if (group == 10){
                group = 0;
                log.info("使用了 {} 个 {}", count,name);
            }
            if (count == 50)break;
        }
        log.info("使用了 {} 个 {}", count,name);
    }
}
